/**
 * 用户相关请求模块
 */

import request from '@/utils/request'
import qs from 'qs'

interface User {
  phone: string
  password: string
}

export const login = (data: User) => {
  return request({
    method: 'POST',
    url: '/front/user/login',
    headers: { 'content-type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(data) // axios 默认发送的是 application/json 格式的数据
  })
}

export const getInfo = () =>
  request({
    method: 'GET',
    url: '/front/user/getInfo'
  })

export const getUserPages = (data: any) =>
  request({
    method: 'POST',
    url: '/boss/user/getUserPages',
    data
  })

export const allocateUserRoles = (data: any) =>
  request({
    method: 'POST',
    url: '/boss/role/allocateUserRoles',
    data
  })

export const roleAll = () =>
  request({
    method: 'GET',
    url: '/boss/role/all'
  })

export const userId = (userId: any) =>
  request({
    method: 'GET',
    url: `/boss/role/user/${userId}`
  })
